#!/bin/sh

echo 'AUTODETECT =' >> /etc/initrd.mk
echo 'FEATURES += propagator' >> /etc/initrd.mk

kver="$(find /lib/modules -mindepth 1 -maxdepth 1 -printf '%f\n' -quit)"

if make-initrd --no-checks --no-depmod -k "$kver"; then
	pdir="$(getconf LIBDIR)/propagator"
	mkdir -p "$pdir"
	gzip < /boot/initrd-$kver.img > "$pdir"/initfs
else
	echo "make-initrd failed"
	exit 1
fi

[ -h /boot/vmlinuz ] || ln -s vmlinuz-"$kver" /boot/vmlinuz
[ -h /boot/initrd.img ] || ln -s initrd-"$kver".img /boot/initrd.img
